package com.gitee.feizns.quickstart.dict.validation.validator;

import com.gitee.feizns.quickstart.dict.Dict;
import com.gitee.feizns.quickstart.dict.validation.constraints.Values;
import com.gitee.feizns.quickstart.validation.validator.AbstractAllMatchConstraintValidator;
import com.jayway.jsonpath.JsonPath;

import java.util.Set;

/**
 * 字典值验证
 * @author feizns
 * @since 2023/2/5
 */
public class ValuesConstraintValidator extends AbstractAllMatchConstraintValidator<Values, Object> {

    @Override
    protected Set<Object> initializeValues(Values constraintAnnotation) {
        return Dict.value().find(JsonPath.compile(annotation.value())).setValue();
    }

}